﻿<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/taglib.jsp"%>
<%@ include file="/WEB-INF/jsp/include/script.jsp" %>   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>DataConverge</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link type="text/css" rel="stylesheet" href="css/xtree.css">
	<script src="js/xtree.js"></script>  
	<script type="text/javascript">		
		function getFrameValues(){		
			var parentNode=document.getElementById("tagIdPlace");
			var docu=document.frames("tagTreeFrame").document;
			var tagId;
			var input;
			for(i=0;i<docu.all.tags.length;i++){
					tagId=docu.all.tags[i].value;
					//alert(tagId);
					input=document.createElement("input");
					input.type="checkbox";
					input.name="tags";
					input.value=tagId;
					parentNode.appendChild(input);
					
					if(docu.all.tags[i].checked==true){
						parentNode.lastChild.checked=true;
					}					
			}
		}
		
		function checkForm(){
			var fo=document.form0;
			var exp = new RegExp("^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$");
			if(fo.subjectName.value==""){
				alert("请填写课题名称");
				return false;
			}
			if(fo.applyFund.value==""){
				alert("请填写申请经费");
				return false;
			}
			if(fo.applyDate.value==""){
				alert("请填写申报日期");
				return false;
			}
			if(!exp.test(fo.applyDate.value)){
      			alert("请确认申报日期的格式!");
     			fo.applyDate.focus();
	  			return false;
	  		}
			if(fo.startDate.value==""){
				alert("请填写课题起始日期");
				return false;
			}
			if(!exp.test(fo.startDate.value)){
      			alert("请确认课题开始日期的格式!");
     			fo.startDate.focus();
	  			return false;
	  		}
			if(fo.endDate.value==""){
				alert("请填写课题结束日期");
				return false;
			}  
			if(!exp.test(fo.endDate.value)){
      			alert("请确认课题结束日期的格式!");
     			fo.endDate.focus();
	  			return false;
	  		}   
			return true;
		}
	</script>
  </head>
  
<body>
<%@ include file="/WEB-INF/jsp/subject/menu.jsp"%>
<form name="form0" action="subjectToAdd.htm" method="post">
<font size="3" color="red"><c:out value="${errorMsg}"/></font>
<IFRAME id="CalFrame"  
  style="DISPLAY: none; Z-INDEX: 100; WIDTH: 148px; POSITION: absolute;HEIGHT: 194px; left: 42px; top: 50px "
  marginWidth="0" marginHeight="0" 
  src="js/calendar/calendars.html" frameBorder="0"  
  noResize scrolling="no">
</IFRAME>
<input name="researcherId" type="hidden" value="${researcherId}"/>
<table width="100%" align="center" height="80%">
<tr>
<td width="30%">
<iframe width="260" height="100%" name="tagTreeFrame" frameborder="0" src="tagTree.htm?oper=add">
</iframe>
</td>

<td width="70%" height="100%">
<table align="right" width="100%" border="1" height="100%">  
  <tr style="display:none;">
  	<td id="tagIdPlace" colspan="2"></td>
  </tr>
  <tr>
    <td>课题名称</td>
    <td><input name="subjectName" type="text" size="50" value="${sub.subjectName}"/><font color="red">*</font></td>
  </tr>
  <tr>
    <td>课题所属年份</td>
    <td><input name="belongYear" type="text" value="${sub.belongYear}"/></td>
  </tr>
  <tr>
	<td>申请经费</td>
    <td><input name="applyFund" type="text" 
    <c:if test="${sub.applyFund!=null}">value="${sub.applyFund}" </c:if>
    <c:if test="${sub.applyFund==null}">value="0.0" </c:if> />（万元）<font color="red">*</font></td>
  </tr>
  <tr>
    <td>申报日期</td>
    <td><input name="applyDate" type="text" 
    <c:if test="${sub.applyDateString!=null}">value="${sub.applyDateString}" </c:if>
    <c:if test="${sub.applyDateString==null}">value="${today}" </c:if>
    onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);" /><font color="red">*</font>
     <font color="red">日期格式：yyyy-mm-dd</font></td>
  </tr>
  <tr>
    <td>研究起始日期</td>
    <td><input name="startDate" type="text" 
    <c:if test="${sub.startDateString!=null}">value="${sub.startDateString}"</c:if>
    <c:if test="${sub.startDateString==null}">value="${today}"</c:if>
    onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);" /><font color="red">*</font><font color="red">日期格式：yyyy-mm-dd</font></td>
  </tr>
  <tr>
    <td>研究结束日期</td>
    <td><input name="endDate" type="text" 
    value="${sub.endDateString}" 
    onClick="ShowCalendar(this,this,null,0);" onkeydown="HideCalendar();" onblur="setFormatDate(this);" /><font color="red">*</font><font color="red">日期格式：yyyy-mm-dd</font></td>
  </tr>
  <tr>
    <td>项目内容概述</td>
    <td><textarea name="content" rows="13" cols="40">${sub.content}</textarea></td>
  </tr>
</table>
</td>
</tr>
</table>
<div align="center"><input name="submit" type="submit" value="提交申报" onclick="getFrameValues();return checkForm();"/></div>
</form>
  </body>
</html>
